/**
 * 这是所有与身份验证相关的表单对话框的基类。它可以选择
 * 能够自动完成支持任何孩子TextField，浏览器或插件
 * 可以恢复/持久化用户名、密码和其他属性。
 */
Ext.define('Jason.view.protal.authentication.Dialog', {
    extend: 'Ext.form.Panel',
    xtype: 'authdialog',
    requires: [
        'Jason.view.protal.authentication.AuthenticationController',
        'Ext.form.Panel'
    ],

    controller: 'authentication',
    viewModel: {
        type: 'authentication'
    },

    /*
     * Seek out the first enabled, focusable, empty textfield when the form is focused
     */
    defaultFocus: 'textfield:focusable:not([hidden]):not([disabled]):not([value])',

    /**
     * @cfg {Boolean} [autoComplete=false]
     * Enables browser (or Password Managers) support for autoCompletion of User Id and
     * password.
     */
    autoComplete: false,

    initComponent: function () {
        var me = this, listen;

        if (me.autoComplete) {
            // Use standard FORM tag for detection by browser or password tools
            me.autoEl = Ext.applyIf(
                me.autoEl || {},
                {
                    tag: 'form',
                    name: 'authdialog',
                    method: 'post'
                });
        }
        //		me.bodyStyle= 'background: #35394a;background: -webkit-gradient(linear, left bottom, right top, color-stop(0%, #35394a), color-stop(100%, rgb(0, 0, 0)));background: -webkit-linear-gradient(230deg, rgba(53, 57, 74, 0) 0%, rgb(0, 0, 0) 100%);background: linear-gradient(230deg, rgba(53, 57, 74, 0) 0%, rgb(0, 0, 0) 100%);'
        //        me.bodyStyle="background: #35394a;";
        //        me.style="background: #35394a;background: rgb(255 255 255 / 3%);-webkit-box-shadow: 10px 10px 5px 0px rgb(0 0 0 / 75%);-moz-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);box-shadow: 10px 10px 5px 0px rgb(255 255 255 / 75%);border-bottom-left-radius: 20px;border-top-left-radius: 20px;";
        me.addCls('auth-dialog');
        me.callParent();

        if (me.autoComplete) {
            listen = {
                afterrender: 'doAutoComplete',
                scope: me,
                single: true
            };

            Ext.each(me.query('textfield'), function (field) {
                field.on(listen);
            });
        }
    },

    doAutoComplete: function (target) {
        if (target.inputEl && target.autoComplete !== false) {
            target.inputEl.set({ autocomplete: 'on' });
        }
    }
});
